using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;

namespace org.synthful.Windows.Forms
{
    public class PopupMenuFileItem : PopupMenuItem
    {
        public PopupMenuFileItem(string path)
        {
            InitializeComponent();
            this.resolvePath(path);
            this.FilePath = path;
        }

        public string _FilePath;

        [System.ComponentModel.Browsable(true),
        System.ComponentModel.Description("File"),
        System.ComponentModel.Category("Appearance")
        ]

        public string FilePath
        {
            get
            {
                if (this._FilePath==null || this._FilePath.ToString().Length == 0)
                    if (base.Text != null && base.Text.Length > 0)
                        this._FilePath = base.Text;

                return this._FilePath;
            }
            set
            {
                this._FilePath = value;
                this.ToolTipText = value.ToString();
            }
        }

        new public string Text
        {
            get
            {
                if (base.Text == null || base.Text.Length==0)
                    if (this._FilePath != null && this._FilePath.ToString().Length > 0)
                        return this._FilePath.ToString();

                return base.Text;
            }
            set
            {
                base.Text = value;
            }
        }

        override protected void whenClicked(object sender, EventArgs e)
        {
            try
            {
                this.RootDropDown.PopupMenuFileItemMouseClick(this, this.ClickedMouseEventArgs);
            }
            catch
            {
            }
        }
    }
}
